<template>
  <BasicTable @register="registerTable"></BasicTable>
</template>
<script setup lang="ts">
import { watch } from 'vue'
import { BasicTable, useTable } from '@/components/Table'
import { getWaterYieldTable } from '@/api/power/water/pureWater/redirect'
import { YieldTableColumn } from './data'

const props = defineProps({
  searchInfo: {
    type: Object,
    default: () => ({}),
  },
})

defineOptions({ name: 'YieldTable' })

const [registerTable, { reload }] = useTable({
  title: '预算数据',
  immediate: false,
  api: getWaterYieldTable,
  columns: YieldTableColumn,
  bordered: true,
  striped: true,
  pagination: false,
  beforeFetch: (params) => props.searchInfo,
})
watch(
  () => props.searchInfo,
  (newValue) => {
    if (Object.values(newValue).length > 0) {
      reload()
    }
  },
  { immediate: true },
)
</script>
<style scoped lang="scss"></style>
